package com.xmutca.sso.dao;

import com.xmutca.core.mybatis.MyBatisDao;
import com.xmutca.sso.api.Account;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

/**
 * @author: 彭伟煌(pengweihuang@xmutca.com)
 * @create: 2016-08-08 15:40
 */
@MyBatisDao
public interface AccountDao {

    /**
     * 根据用户名获取用户
     * @param username
     * @return
     */
    @Select("select * from t_sys_user where username = #{username}")
    Account getByUsername(String username);

    /**
     * 根据用户id获取用户
     * @param id
     * @return
     */
    @Select("select * from t_sys_user where id = #{id}")
    Account getById(String id);

    /**
     * 更新密码
     * @param password
     * @param id
     * @return
     */
    @Update("update t_sys_user set password = #{password} where id = #{id}")
    int updatePassword(@Param("password") String password, @Param("id") String id);

    /**
     * 查询数据
     * @param paramMap
     * @return
     */
    List<Account> query(Map<String, Object> paramMap);

    /**
     * 统计查询数据记录数
     * @param paramMap
     * @return
     */
    int countQuery(Map<String, Object> paramMap);
}
